#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
void swap(const void*p1, const void*p2, int len)
{
	char tmp = 0;
	for (int i = 0; i < len; i++)
	{
		tmp = *((char*)p1 + i); 
		*((char*)p1 + i) = *((char*)p2 + i);
		*((char*)p2 + i) = tmp;
	}
}
void Bubble_sort(void * p,int num,int one_len,int (*psort)(const void*, const void*))
{
	for (int i = 0; i < num - 1; i++)
	{
		for (int j = 0; j < num - i - 1; j++)
		{
			if (psort((char*)p + j * one_len, (char*)p + one_len * (j + 1)) > 0)
				swap((char*)p + j * one_len, (char*)p + one_len * (j + 1),one_len);
		}
	}
}
int sort(const void* p1, const void*p2)
{
	if (*(int*)p1 > *(int*)p2)
		return 1;
	else if (*(int*)p1 == *(int*)p2)
		return 0;
	else
		return -1;
}
int main()
{
	int arr[10] = { 3,2,4,5,6,9,8,7,1,10 };
	int sz = sizeof(arr) / sizeof(arr[1]);
	Bubble_sort(arr, sz, sizeof(arr[0]), sort);
	for (int i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}